package forestsimulatorp3.model.beings.abstrakt;

import forestsimulatorp3.model.beings.Environment;
import model.enums.Gender;
import model.enums.Movement;
import forestsimulatorp3.model.position.Square;
import forestsimulatorp3.model.position.Area;

/**
 * Represents an animal on the forest
 * @author dielson
 *
 */
public abstract class Animal extends LivingBeing {

    // Attributes --------------------------------------------------------------

    private Gender gender;

    // Constructors ------------------------------------------------------------

    public Animal(long id, String speciesName, Gender gender, Environment environment,
            int lifePoints, Square position) {
        super(id, speciesName, environment, lifePoints, position);
        this.gender = gender;
    }

    // Public methods ----------------------------------------------------------
    /**
     * Moves the animal from one position to another.
     * @param movement the movement direction.
     * @return true if the movement was well succeeded; false in the other hand
     */
    public void move(Movement movement) {
        Square from = getPosition();
        Square to = getEnvironment().getArea().getNext(from, movement);
        Square result = getEnvironment().moveTo(from, to);
        setPosition(result);

        getEnvironment().getLogger().notifyAction(this + " moveu-se da posição " + from + " para a posição " + getPosition());
    }

    @Override
    public void rest() {
        setLifePoints(getLifePoints() + 3);
    }

    // Private methods ---------------------------------------------------------

    // Getters & setters -------------------------------------------------------
    public Gender getGender() {
        return gender;
    }
}
